/*
 *  (C) Copyright 2007 Insula Tecnologia da Informacao Ltda.
 * 
 *  This file is part of Jazz.
 *
 *  Jazz is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Jazz is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Jazz.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openinsula.jazz.resolver.echopointng;

import static org.junit.Assert.assertEquals;

import java.util.Calendar;
import java.util.GregorianCalendar;

import org.junit.Test;

import echopointng.DateField;

public class DefaultDateFieldResolverTestCase {

	private DateField dateField = new DateField();

	private DefaultDateFieldResolver resolver = new DefaultDateFieldResolver();

	@Test
	public void testGetValue() {
		Calendar calendar = new GregorianCalendar(2008, Calendar.MARCH, 17, 10, 00, 00);

		dateField.setSelectedDate(calendar);
		assertEquals(calendar.getTime(), resolver.getValue(dateField));

		calendar = new GregorianCalendar(2007, Calendar.DECEMBER, 4, 12, 00, 00);
		dateField.setSelectedDate(calendar);
		assertEquals(calendar.getTime(), resolver.getValue(dateField));
	}

	@Test
	public void getSetValue() {
		Calendar calendar = new GregorianCalendar(2008, Calendar.MARCH, 17, 10, 00, 00);

		resolver.setValue(dateField, calendar.getTime());
		assertEquals(calendar.getTime(), dateField.getSelectedDate().getTime());

		calendar = new GregorianCalendar(2007, Calendar.DECEMBER, 4, 12, 00, 00);

		resolver.setValue(dateField, calendar.getTime());
		assertEquals(calendar.getTime(), dateField.getSelectedDate().getTime());
	}
}
